#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 2e5 + 5;
int col[N],n,T,ans;//col - 1 / 2;
int a[N];

int Sum(){
    int sum = 0;
    for(int i=1;i<=n;i++){
        int f = i - 1;
        while(f > 0 && col[i] != col[f])
            f --;
        if(f == 0) continue;
        if(a[f] == a[i]) sum += a[f];
    }
    return sum;
}

void dfs(int dep){
    if(dep == n + 1){
        ans = max(ans,Sum());
        return ;
    }
    col[dep] = 1;
    dfs(dep + 1);
    col[dep] = 2;
    dfs(dep + 1);
    col[dep] = 0;
}

signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n;
        for(int i=1;i<=n;i++)
            cin>>a[i];
        ans = 0;
        dfs(1);
        cout<<ans<<endl;
    }
    return 0;
}
